package com.chandra.pos.product.service.impl;

import com.chandra.pos.product.model.ProductFilter;
import com.chandra.pos.product.model.ProductList;
import com.chandra.pos.product.model.ProductModel;
import com.chandra.pos.product.service.ProductManager;
import com.chandra.pos.product.service.ProductRole;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.persistence.EntityNotFoundException;

/**
 * Created by Admin on 7/3/14.
 */
@Service
public class ProductManagerImpl implements ProductManager {

    @Autowired
    ProductRole productRole;


//    @Override
//    public List<Product> search(String name) {
//
//
//        List<Product> products = new ArrayList<>();
//
//        Product p1 = new Product();
//        p1.setProductId(1l);
//        p1.setName("ACC");
//        p1.setDescription("ACC Cements");
//        p1.setPrice(new BigDecimal(340.00));
//        products.add(p1);
//
//        Product p2 = new Product();
//        p2.setProductId(2l);
//        p2.setName("Lafarge");
//        p2.setDescription("Lafarge Cements");
//        p2.setPrice(new BigDecimal(320.00));
//        products.add(p1);
//
//
//        Product p3 = new Product();
//        p3.setProductId(3l);
//        p3.setName("ACC Plus");
//        p3.setDescription("ACC Plus Cements");
//        p3.setPrice(new BigDecimal(370.00));
//        products.add(p3);
//
//
//        Product p4 = new Product();
//        p4.setProductId(4l);
//        p4.setName("KC Super");
//        p4.setDescription("KC Super Cements");
//        p4.setPrice(new BigDecimal(300.00));
//        products.add(p4);
//
//
//        Product p5 = new Product();
//        p5.setProductId(1l);
//        p5.setName("Tata TMT");
//        p5.setDescription("Tata Tiscon TMT");
//        p5.setPrice(new BigDecimal(270.00));
//        products.add(p5);
//
//
//        Product p6 = new Product();
//        p6.setProductId(1l);
//        p6.setName("Siscon TMT");
//        p6.setDescription("Siscon TMT Bar");
//        p6.setPrice(new BigDecimal(240.00));
//        products.add(p6);
//
//
//        return products;
//    }

    @Override
    public ProductList search(ProductFilter name) {
        return productRole.search(name);
    }


    public ProductModel saveProduct(ProductModel productModel) {


        return productRole.saveProduct(productModel);
    }

    @Override
    public ProductModel getProductDetail(ProductFilter query) throws EntityNotFoundException {
        return productRole.getProductDetail(query);
    }
}
